public class demo1 {
    public String longestPalindrome(String s) {
        if(s.length()<2)return s;
        String ret="";
        for(int i=0;i<s.length();i++){
            for(int j=i+1;j<s.length();j++){
                if(ifhuiwen(s.substring(i,j+1))){
                    if(j-i>=ret.length()){
                        ret=s.substring(i,j+1);
                    }
                }
            }
        }
        if(ret=="")return s.substring(0,1);
        return ret;
    }
    public boolean ifhuiwen(String s){
        int left=0;
        int right=s.length()-1;
        while(left<right){
            if(s.charAt(left)!=s.charAt(right))return false;
            left++;
            right--;
        }
        return true;
    }
}
